import axios from "axios";

var instance = axios.create({
    baseURL: 'url',
    timeout: 20000,
    
});

//token 添加到请求头
export const $setToken = (token)=>{
    instance.defaults.headers.common['token'] = token;
}

//get
export const $get = async (url, params) => {
    let { data } = await instance.get(url, {
        params
    })
    return data
}

//post
export const $post = async (url, params) => {
    let { data } = await instance.post(url, params)
    return data

}

//put
export const $put = async (url, params) => {
    let { data } = await instance.post(url, params)
    return data
}

//del
export const $delete = async (url, params) => {
    let { data } = await instance.delete(url, {
        params
    })
    return data
}